import java.io.*;
import java.util.*;

/*
 ID: ning yusui
 LANG: JAVA
 TASK: contact
 */

public class contact {
    Scanner in;
    PrintWriter out;


    public contact() throws IOException {
        in = new Scanner(new File(this.getClass().getName() + ".in"));
        out = new PrintWriter(new BufferedWriter(new FileWriter(this.getClass().getName() +
                ".out")));
    }


    private void work() {
        int a = in.nextInt();
        int b = in.nextInt();
        int n = in.nextInt();
        int[] cnt = calc(a, b);
        Map<Integer, List<Stats>> result = statsResult(n, cnt);
        outPut(result);
        out.flush();
        out.close();
    }

    private int[] calc(int a, int b) {
        int length = b - a + 1;
        int patterns[] = new int[length];
        int flags[] = new int[length];
        for (int i = 0; i < length; i++) {
            patterns[i] = 1;
            flags[i] = 1 << (a + i);
        }
        int cnt[] = new int[1 << b + 2];
        for (; in.hasNext(); ) {
            String next = in.next();
            for (int i = 0; i < next.length(); i++) {
                char ch = next.charAt(i);
                int bit = ch == '1' ? 1 : 0;
                for (int j = 0; j < length; j++) {
                    if (patterns[j] >= flags[j]) {
                        patterns[j] = ((patterns[j] ^ flags[j]) << 1) | bit | flags[j];
                    } else {
                        patterns[j] = (patterns[j] << 1) | bit;
                    }
                    if (patterns[j] >= flags[j]) {
                        cnt[patterns[j]]++;
                    }
                }
            }
        }
        return cnt;
    }

    private Map<Integer, List<Stats>> statsResult(int n, int[] cnt) {
        Stats[] statses = new Stats[cnt.length];
        int size = 0;
        for (int i = 0; i < cnt.length; i++) {
            if (cnt[i] > 0) {
                statses[size++] = new Stats(i, cnt[i]);
            }
        }
        Arrays.sort(statses, 0, size);
        return buildResult(n, statses, size);
    }

    private Map<Integer, List<Stats>> buildResult(int n, Stats[] statses, int size) {
        Map<Integer, List<Stats>> result = new TreeMap<Integer, List<Stats>>(new Comparator<Integer>() {
            public int compare(Integer o1, Integer o2) {
                return o2 - o1;
            }
        });
        for (int i = 0, j = 0; i < size; i++) {
            int key = statses[i].count;
            List<Stats> value = result.get(key);
            if (value != null) {
                value.add(statses[i]);
            } else {
                if (j < n) {
                    value = new ArrayList<Stats>();
                    value.add(statses[i]);
                    result.put(key, value);
                    j++;
                } else {
                    break;
                }
            }
        }
        return result;
    }

    private void outPut(Map<Integer, List<Stats>> result) {
        for (Map.Entry<Integer, List<Stats>> entry : result.entrySet()) {
            out.println(entry.getKey());
            List<Stats> value = entry.getValue();
            for (int i = 0; i < value.size(); i++) {
                out.print(Integer.toBinaryString(value.get(i).pattern).substring(1));
                if (i % 6 == 5 || i == value.size() - 1) {
                    out.println();
                } else {
                    out.print(' ');
                }
            }
        }
    }

    public static void main(String[] args) throws IOException {
        long start = System.currentTimeMillis();
        new contact().work();
        System.out.println(System.currentTimeMillis() - start + "ms");
    }

    static class Stats implements Comparable<Stats> {
        int pattern;
        int count;

        Stats(int pattern, int count) {
            this.pattern = pattern;
            this.count = count;
        }

        public int compareTo(Stats o) {
            if (this.count == o.count) {
                return this.pattern - o.pattern;
            }
            return o.count - this.count;
        }
    }
}
